package com.mfhcd.facepay.activity

import android.annotation.SuppressLint
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.jakewharton.rxbinding3.view.clicks
import com.mfhcd.facepay.R
import com.mfhcd.facepay.base.BaseActivity
import com.mfhcd.facepay.constant.ArouterUrl
import com.mfhcd.facepay.databinding.ActivityTransResultBinding
import com.mfhcd.facepay.model.TitleBean
import com.mfhcd.facepay.model.TypeModel
import com.mfhcd.facepay.viewmodel.BaseViewModel
import java.util.concurrent.TimeUnit

@Route(path = ArouterUrl.ACTIVITY_TRANS_RESULT)
class TransResultActivity : BaseActivity<BaseViewModel, ActivityTransResultBinding>() {
    companion object {
        const val  RESULT_DATA = "result_data"
    }

    @Autowired(name = RESULT_DATA)
    lateinit var resultModel: TypeModel

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_trans_result)
        mBaseBinding.titleBean = TitleBean("交易结果")
    }

    override fun initData() {
        bindingView.result = resultModel
    }

    @SuppressLint("CheckResult")
    override fun initListener() {
        bindingView.btnConfirm.clicks()
                .throttleFirst(1, TimeUnit.SECONDS)
                .subscribe {
                    finish()
                }
    }
}
